package com.lianjinsu.shop.controller.vo;

import lombok.Getter;

@Getter
public class Response<T> {

    private final Integer status;

    private final String message;

    private final T data;

    private Response(Integer status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    private Response(String message, T data) {
        this(0, message, data);
    }

    private Response(T data) {
        this(null, data);
    }

    private Response() {
        this(null, null);
    }

    public static <E> Response<E> ok() {
        return new Response<>();
    }

    public static <E> Response<E> ok(E data) {
        return new Response<>(data);
    }

    public static <E> Response<E> fail(String message) {
        return new Response<>(-1, message, null);
    }
}
